/*
*  LLFileData.cpp
*  
*
*  Created by Alexander Trutchenko on 11/02/12.
*  Copyright 2012 Free Team. All rights reserved.
*
*/

#include "lid_lib/src/file_managment/LLFileData.h"

#include "lid_lib/src/file_managment/LLFileUtils.h"
#include "lid_lib/src/service/LLAssert.h"

#include <stdio.h>
#include <string.h>

namespace lidlib {

////////////////////////////////////////////////////////
//
/** LLFileData
*  
*/
////////////////////////////////////////////////////////

LLFileData::LLFileData(const char* filePath)
: _data(NULL)
, _size(0)
, _fileName(filePath)
{
	_data = LLFileUtils::getFileData(LLFileUtils::fullPathFromRelativePath(filePath), &_size);
//	LLAssert(_data != NULL && _size != 0, "LLFileData::LLFileData(): Can't read file %s", filePath);
}
LLFileData::LLFileData(const LLFileData& fileBuffer)
{
	_size = fileBuffer._size;
	_fileName = fileBuffer._fileName;
	_data = new unsigned char[_size];
	memcpy(_data, fileBuffer._data, _size);
}
LLFileData& LLFileData::operator = (const LLFileData& fileBuffer)
{
	delete [] _data;
	_size = fileBuffer._size;
	_fileName = fileBuffer._fileName;
	_data = new unsigned char[_size];
	memcpy(_data, fileBuffer._data, _size);

	return *this;
}

LLFileData::~LLFileData()
{
	delete [] _data;
}
} // namespace lidlib
